$(function (){
    var reqData={}
    listData(reqData);

})
function listDataByDate(){
    var reqData={};
    reqData.begin=$("#begin").val();
    reqData.end=$("#end").val();
    listData(reqData);

}
function listData(reqData){
    var url=$("#listData").val();
    console.log("url:::"+url);
    $.ajax({
        type: "POST",  // post, get, put, delete
        url: url, // 请求的URL
        data: JSON.stringify(reqData),  // 请求的数据
        dataType: "json",   // 返回的数据类型，json, html, xml, jquery.parseJson()
        contentType: "application/json;charset=utf-8",  // 请求的数据格式，字符集
        async: true, // 可以不写， 是否异步请求
        success: function (data) {
            console.log("code::: " + data.code);
            console.log("msg::: " + data.msg);
            console.log("data::: " + data.data);
            var d=data.data;
            var str='';
            for(var i=0;i<d.length;i++){
                var id=d[i].id;
                var deptid=d[i].deptid;
                var deptname=d[i].deptname;
                var areaid=d[i].areaid;
                var areaname=d[i].areaname;
                var name;
                if(data.role==4){
                    name=areaname;
                }if(data.role==3){
                    name=deptname;
                }
                console.log("name::"+name);
                var plannum=d[i].plannum;
                var itemnum=d[i].itemnum;
                var rate=zhuanhuan(d[i].rate);
                var rank=d[i].rank;
                var sumnewclient=d[i].sumnewclient;
                var sumoldclient=d[i].sumoldclient;
                var sumyxclient=d[i].sumyxclient;
                var summoney=d[i].summoney;
                console.log("deptid"+deptid);
                str+="<tr><td>"+name+"</td><td>"+plannum+"</td>" +
                    "<td>"+itemnum+"</td><td>"+rate+"</td>" +
                    "<td>"+rank+"</td><td>"+sumnewclient+"</td>" +
                    "<td>"+sumoldclient+"</td><td>"+sumyxclient+"</td>" +
                    "<td>"+summoney+"</td></tr>";
            }
            $("#list").html(str);
        }
    });
}

function zhuanhuan(data){
    var str = Number( data* 100 ).toFixed(1);
    str+="%";
    return str;

}